import axios from 'axios'
import { ElMessage } from 'element-plus'

const instance = axios.create({
    baseURL: '/api',
    timeout: 5000,
    withCredentials: true
})

instance.interceptors.response.use(function (response) {
    if (response.data.code !== 0){
        ElMessage.error(response.data.message)
    }
    return response.data;
}, function (error) {
    ElMessage.error("系统内部异常");
    return Promise.reject(error);
});

export default instance
